<?php
/**
 * 系統名稱: Lotto 系統
 * 檔案說明: 專案管理-修改
 * $Author$
 * $Id$
 *
 */
include_once("../config.inc.php");

session_start();
if(!isset($_SESSION["Member_Info"]) || !is_object($_SESSION["Member_Info"]))return;
if($_COOKIE["Member_CKey"] != $_SESSION["Member_Info"] -> CKey)return;

//$_intLang = $_SESSION["Mem_LanguageNo"];
//$_Charset = $_SESSION["Mem_Charset"];

//include_once(__Root_Path."/getvars.inc.php");
//include_once(__Member_Path."logincheck.php");
//include_once(__Language_Path."/selectlanguage_member.php");
//include_once(__Common_Path."/Lotto.inc.php");
include_once(__Language_Path."/lang_member/thesame_1.lang.php");
include_once(__Modules_Path."/ChangeTime.lib.php");
include_once(__Common_Path."/todaygame/Gamble".$_data["LottoID"].".inc.php");
include_once(__Common_Path."/gambletype/GambleType".$_SESSION["Member_Info"] -> GambleType."_".$_data["LottoID"].".inc.php");
if($_data["sType"] != "o")include_once(__Root_Path."/tmp/credit-".$_SESSION["Member_Info"] -> ID.".php");

//是否顯示球的賠率
$isShow = true;

//取得 TodayGame 資料
$arrBType = split(",", $_data["Bet_Type"]);
foreach($arrBType as $strBT){
	include(__Common_Path."/todaygame/TodayGame".$_data["LottoID"]."_".$strBT.".inc.php");
}

//取得樂透相關資料
//$arrTmp = split("-", $_arrLotto[$_data["LottoID"]]["Number"]);
//for($i = intval($arrTmp[0]); $i <= intval($arrTmp[1]); $i++)$_strNumber .= $i.",";
//$_strNumber = substr($_strNumber, 0, strlen($_strNumber) - 1);
$isShowScore = false;
$NowDate = date("Y-m-d");
$NowTime = date("H:i:s");

//取的 Gamble 設定資料
if(!is_array($_arrGamble)){
	//$GLOBALS["errormessage"] = "No Game Data!!";
	//include(__Root_Path."/error.php");
	$isShow = false;
	$intGTime = 0;
}else{
	list($intGID, $arrGData) = each($_arrGamble);
	
	if($arrGData["GameDate"] == $NowDate && $NowTime > $arrGData["EndGameTime"])$isShowScore = true;
	//print $arrGData["GameDate"]." == ".$NowDate." == ".$NowTime." == ".$arrGData["EndGameTime"];
	//$_strGDate = DateForm($arrGData["GameDate"], $arrGData["GameTime"], "Y-m-d", "UToC")." ".TimeForm($arrGData["GameDate"], $arrGData["GameTime"], "H:i", "UToC");
	$arrGTime = explode(":", $arrGData["GameTime"]);
	$arrGDate = explode("-", $arrGData["GameDate"]);
	$intGTime = mktime($arrGTime[0], $arrGTime[1], $arrGTime[2], $arrGDate[1], $arrGDate[2], $arrGDate[0]) - time();
	if($arrGData["GameDate"] < $NowDate)$isShow = false;
	$EndGameTime = ((int)$_data["isSpecial"] == 1 || (int)$_data["isSpecial"] == 28)?$arrGData["EndGameTimeSN"]:$arrGData["EndGameTime"];
	if($arrGData["GameDate"] == $NowDate && $EndGameTime < $NowTime)$isShow = false;
	if(!is_array($_arrTodayGame[$intGID])){
		$isShow = false;
	}
}

$isAllStopWager = true;
if($isShow){
	//$strParentID = $_SESSION["Member_Info"] -> SubID.",".$_SESSION["Member_Info"] -> MainID.",".$_SESSION["Member_Info"] -> StockID;
	while(list($intBID, $arrB) = each($_arrTodayGame[$intGID])){
		//$arrStop = GetStopRealBet($intGID, $_data["Bet_Type"], $strParentID, 0);
		while(list($intNID, $Rows) = each($arrB)){
			//if(($arrStop["parent"][$Rows["GambleID"]][$Rows["Bet_Type"]][$Rows["Number"]] + $Rows["isStopBet"]) > 0)$Rows["isStopBet"] = 1;
			$intApointNum = $_arrGLineNumToApointNum[$Rows["LottoID"]][$Rows["Bet_Type"]][$Rows["Number"]];
			if($intApointNum == null)$intApointNum = 0;

			$strCon .= "parent.Game".$Rows["Bet_Type"]."[".$Rows["Number"]."]=new Array('".$Rows["LottoID"]."','".$Rows["GambleID"]."','".$Rows["Bet_Type"]."','".$Rows["Number"]."','".$Rows["OddsID"]."','".($Rows["Odds"]+$_arrGambleType[$Rows["Bet_Type"]][$intApointNum])."','".$Rows["isStopBet"]."');\n";

			if($_data["sType"] != "o"){
				$arrLimit[$Rows["Number"]] = $_arrMemStake[$Rows["Bet_Type"]][$Rows["GambleID"]][$Rows["Number"]];
				if(empty($arrLimit[$Rows["Number"]]))$arrLimit[$Rows["Number"]] = 0;
			}

			if($Rows["isStopBet"] == 0)$isAllStopWager = false;
		}  // while(list($intNID, $Rows) = each($arrB))  //

		if($_data["sType"] != "o"){
			$strLimit .= "parent.arrEveLimitUsed[".$intBID."]=new Array(".join(",", $arrLimit).");\n";
			unset($arrLimit);
		}  // if($_data["sType"] != "o") //
	}  // while(list($intBID, $arrB) = each($_arrTodayGame[$intGID])) //
}  // if($isShow) //

if($isAllStopWager)$isShow = false;
//已使用信用額度
$intUseCredit = (empty($_arrMemStake["_SUM"]))?0:$_arrMemStake["_SUM"];
$arrCheckKey = split(" ", microtime());
/*=================================================================*/
header("Cache-Control: no-store, no-cache, must-revalidate");	  // HTTP/1.1
header("Cache-Control: post-check=0, pre-check=0", false);
header("Pragma: no-cache");															  // HTTP/1.0
?><script language="JavaScript">
<!--
<?php print $strCon.$strLimit;?>
parent.sType = "<?php print $_data["sType"];?>"
parent.strGameTime = "<?php print $intGTime;?>";
parent.strGameNo = "<?php print $arrGData["SerialNo"];?>";
parent.strChinaTime = "<?php print DateForm(date("Y-m-d"), date("H:i:s"), "m-d", "UToC")." ".TimeForm(date("Y-m-d"), date("H:i:s"), "H:i:s", "UToC");?>";
parent.strCheckKey1 = "<?php print $arrCheckKey[0];?>";
parent.strCheckKey2 = "<?php print $arrCheckKey[1];?>";
parent.UseCredit = <?php print $intUseCredit;?>;
<?php if($isShow){ ?>parent.ShowNumberOdds_C(<?php print $_data["isSpecial"];?>);<?php } ?>
parent.strDisplay = "none";
//-->
</script>
<?php
if($_data["sType"] == "o" || $_data["sType"] == "c"){
	if($isShowScore){
		include("showscore.php");
	}else{
		print "<script>parent.ShowScore();</script>\n";
	}
}
?>